﻿using System;
using System.Windows.Forms;

namespace WindowsApplication2._18_设计模式.基础.继承._2
{
    public partial class Form1 : Form
    {
        int flag = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            if (flag == 0)
            {
                double_rectangle dr = new double_rectangle(10, 20, 70, 100);
                dr.draw(e.Graphics);
            }
            else if (flag == 1)
            {
                rectangle dr = new rectangle(10, 20, 70, 100);
                dr.draw(e.Graphics);
            }

            base.OnPaint(e);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //rectangle r = new rectangle(10, 20, 70, 100);
            if (flag == 0) flag = 1;
            if (flag == 1) flag = 0;
            this.Refresh();
        }
    }
}